package mq

import (
	"cloud-disk/global/mq"
	"log"
)

func StartConsumer(qName, cName string, processFunc func(msg []byte) bool) {
	contentC, err := mq.Channel().Consume(qName, cName, true, false, false, false, nil)
	if err != nil {
		log.Printf("failed to consume , err :%v\n", err.Error())
		return
	}
	doneConsumer := make(chan struct{})
	defer close(doneConsumer)

	go func() {
		for content := range contentC {
			ok := processFunc(content.Body)
			// todo
			if !ok {
			}
		}
	}()

	<-doneConsumer
}
